<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>模块管理</title>
    <link rel="stylesheet" type="text/css" th:href="@{/css/style.css}"/>
    <script type="text/javascript" th:src="@{/js/jquery.js}"></script>
    <script type="text/javascript">
        function tipOpen(ele) {
            var mid =$(ele).prev().prev().val();
            var state = $(ele).prev().val();
            console.log("id"+mid+"state"+state);
            if (state == 1) {
                $(".tipright p").text("确认禁用该模块？");
            } else {
                $(".tipright p").text("确认启用该模块？")
            }
            $("#moduleId").val(mid);
            $("#tip").fadeIn(200);
        }

        function tipClose() {
            $("#tip").fadeOut(200);
        }
    </script>
</head>

<body>
<div class="place"><span>位置：</span>
    <ul class="placeul">
        <li><a href="../users/userList.html">系统管理</a></li>
        <li><a href="#">模块管理</a></li>
    </ul>
</div>
<div class="rightinfo">
    <form th:action="@{/sys/modules/list}" method="post" id="moduleForm">
        <ul class="tools">
            <input type="hidden" id="pageNum" name="pageNum" value="1">
            <li><label>模块名称:</label>
                <input type="text" name="moduleRname" th:value="${moduleRname}"/>
            </li>
            <li><label>父模块:</label>
                <select name="modulePid">
                    <option value="0">请选择</option>
                    <option th:each="parent:${parentModule}"
                            th:selected="${parent.moduleId==modulePid}"
                            th:value="${parent.moduleId}"
                            th:text="${parent.moduleRname}"></option>
                </select>
            </li>
            <li class="subBut" onclick="goPage(1)"><img th:src="@{/images/t06.png}"/>查询</li>
            <li class="subBut" onclick="reset()"><img th:src="@{/images/t03.png}"/>重置</li>
            <li class="subBut" onclick="window.location.href='/erp/sys/modules/toAdd'">
                <img th:src="@{/images/t01.png}"/>添加
            </li>
        </ul>
        <table class="tablelist">
            <thead>
            <tr>
                <th>序号</th>
                <th>模块名称</th>
                <th>父模块</th>
                <th>URL</th>
                <th>状态</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <tr th:each="m,var:${mp.list}">
                <td th:text="${(mp.pageNum-1)*mp.pageSize+var.count}">1</td>
                <td th:text="${m.moduleRname}">系统管理</td>
                <td th:text="${m.parentModule!=null?m.parentModule.moduleRname:' '}"></td>
                <td th:text="${m.moduleMurl}">#</td>
                <td th:text="${m.moduleState==1?'启用':'禁用'}">正常</td>
                <td>
                    <a th:href="|/erp/sys/modules/toUpdate/${m.moduleId}|" class="tablelink">修改</a>
                    <a th:href="|/erp/sys/modules/details/${m.moduleId}|" class="tablelink">详情</a>
                    <input type="hidden" class="moduleId" name="moduleId" th:value="${m.moduleId}">
                    <input type="hidden" class="moduleState" name="moduleState" th:value="${m.moduleState}">
                    <a href="javascript:void(0);" class="tablelink" onclick="tipOpen(this)"
                       th:text="${m.moduleState==1?'禁用':'启用'}">禁用</a>
                </td>
            </tr>
            </tbody>
        </table>
        <div class="pagin">
            <div class="message">
                共<i class="blue" th:text="${mp.total}">1256</i>条记录，当前显示第&nbsp;<i class="blue" th:text="${mp.pageNum}">2&nbsp;</i>页
            </div>
            <ul class="paginList">
                <li class="paginItem">
                    <a href="javascript:void(0);" th:onclick="goPage([[${mp.isFirstPage?1:mp.pageNum-1}]])">
                        <span th:class="${mp.isFirstPage?'pagepre':'pagenxt roate'}"></span>
                    </a>
                </li>
                <li th:each="page : ${mp.navigatepageNums}"
                    th:class="${page==mp.pageNum?'paginItem current':'paginItem'}">
                    <a href="javascript:void(0);" th:text="${page}" th:onclick="goPage([[${page}]])">1</a>
                </li>
                <li class="paginItem">
                    <a href="javascript:void(0);"
                       th:onclick="goPage([[${mp.isLastPage?mp.pages:mp.pageNum+1}]])">
                        <span th:class="${mp.isLastPage?'pagepre roate':'pagenxt'}"></span>
                    </a>
                </li>
            </ul>
        </div>
    </form>
    <!-- 提示框 -->
    <div id="tip" class="tip">
        <div class="tiptop"><span>提示信息</span><a onclick="tipClose()"></a></div>
        <div class="tipinfo"><span><img src="../../images/ticon.png"/></span>
            <div class="tipright">
                <p></p>
                <cite>如果是请点击确定按钮 ，否则请点取消。</cite></div>
            <input type="hidden" id="moduleId">
        </div>
        <div class="tipbtn">
            <input name="" type="button" class="sure" value="确定" onclick="doState()"/>
            &nbsp;
            <input name="" type="button" class="cancel" value="取消" onclick="tipClose()"/>
        </div>
    </div>
</div>
<script type="text/javascript">
    $('.tablelist tbody tr:odd').addClass('odd');

    function goPage(num) {
        //submit提交
        $("#pageNum").val(num);
        $("#moduleForm").submit();
    }

    function doState() {
    // 启用禁用模块状态
        var moduleId = $("#moduleId").val();
        window.location.href = "/erp/sys/modules/doState/" + moduleId;
    }
    // 清空查询条件
    function reset() {
        $(".tools>li>input").val("");
        $("select[name=modulePid]>option:eq(0)").attr("selected", true);
    }
</script>
</body>
</html>
